# -*- coding: utf-8 -*-
"""
Created on Fri Feb 19 17:08:20 2021

@author: yeamy
"""

import cv2
import time
import RPi.GPIO as GPIO
# import numpy as np
LedPin =12
GPIO.setmode(GPIO.BCM)
GPIO.setup(LedPin, GPIO.OUT)
GPIO.output(12,1)
time.sleep(0.5)
# cap = cv2.VideoCapture(0)
# ret, img = cap.read()
# img=cv2.imread('26.jpg')
cap = cv2.VideoCapture(0)
width = 1900
height =1500
cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
cap.set(cv2.CAP_PROP_FOURCC,cv2.VideoWriter.fourcc("M","J","P","G"))
ret,img = cap.read()
cap.release()

def on_EVENT_LBUTTONDOWN(event, x, y, flags, param):
    if event == cv2.EVENT_LBUTTONDOWN:
        xy = "%d,%d" % (x, y)
        cv2.circle(img, (x, y), 1, (0, 255, 0), thickness = -1)
        cv2.putText(img, xy, (x, y), cv2.FONT_HERSHEY_PLAIN,
                    1.0, (0,0,255), thickness = 1)
        cv2.imshow("image", img)
cv2.namedWindow("image")
cv2.setMouseCallback("image", on_EVENT_LBUTTONDOWN)
while(1):
    cv2.imshow("image", img)
    if cv2.waitKey(0)&0xFF==27:
        break
cv2.destroyAllWindows()
GPIO.output(12,0)